﻿using System.Configuration;
using Tilver.Configuration.Logging;
using Tilver.Configuration.Data;

namespace Tilver.Configuration
{
    /// <summary>
    /// Tilver自定义配置节信息类
    /// </summary>
    public class TilverSection : ConfigurationSection
    {
        private static TilverSection _section;
        
        /// <summary>
        /// 获取指定名称的Tilver自定义配置节信息
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static TilverSection GetSection(string name = "tilver")
        {
            if (_section == null)
            {
                _section = ConfigurationManager.GetSection(name) as TilverSection;
            }
            return _section;
        }
        
        /// <summary>
        /// 日志模块配置节
        /// </summary>
        [ConfigurationProperty("logging")]
        public LoggingConfigElement LoggingConfig
        {
            get { return this["logging"] as LoggingConfigElement; }
            set { this["logging"] = value; }
        }
        /// <summary>
        /// 数据库模块配置节
        /// </summary>
        [ConfigurationProperty("data")]
        public DataConfigElement DataConfig
        {
            get { return this["data"] as DataConfigElement; }
            set { this["data"] = value; }
        }
    }
}
